<?php
/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of AluminioInsertarLogica
 *
 * @author Sondy
 */
class AluminioInsertarLogica extends Comando {
    private $dbAluminioDao = null;
    private $id = null;
    private $aluminio = null;

    function __construct( Aluminio $aluminio , $id ) {
        $this->id = $id;
        $this->aluminio = $aluminio;
    }

    /**
     *  Insertar un Aluminio a la fuente de datos
     *
     * @return boolean
     */
    public function hacer() {
        try {
            $FabricaDAO = FabricaDAO::crearFabricaMySQLDAO();
            $this->dbAluminioDao = $FabricaDAO->crearDBAluminioDAO();

            if( $this->dbAluminioDao->Insert( $this->aluminio, $this->id ) ) {
                return true;
            } else {
                return false;
            }

        } catch ( DBAluminioDAOException $Ex ) {
            throw new AluminioLogicaException("Imposible concetar a la base de datos intente de nuevo", 1);
        }

    }

}
?>
